package com.ysu.his.register.config;

import com.ysu.his.register.interceptor.LoginUserInterceptor;
import com.ysu.his.register.properties.UserProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class UserWebmvcConfig implements WebMvcConfigurer
{
    @Autowired
    private LoginUserInterceptor loginUserInterceptor;

    @Autowired
    private UserProperties userProperties;

     public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginUserInterceptor)
                .excludePathPatterns(userProperties.getNoAuthUrls())
                .addPathPatterns("/**");

    }
}
